package day01_IO_JDBC.demo_JDBC_users.controller;

import day01_IO_JDBC.demo_JDBC_users.Entity.Users;
import day01_IO_JDBC.demo_JDBC_users.dao.Impl.UsersDaoImpl;
import day01_IO_JDBC.demo_JDBC_users.dao.UsersDao;
import day01_IO_JDBC.demo_JDBC_users.service.Impl.UsersServiceImpl;
import day01_IO_JDBC.demo_JDBC_users.service.UsersService;

public class UsersController {
    /*
    * 注册功能
    * */

    public void register(Users users){

//      实例化UsersDaoImpl+ UsersServiceImpl
        UsersDao usersDao = new UsersDaoImpl();
        UsersService usersService= new UsersServiceImpl(usersDao);

        boolean bl= usersService.register(users);
        if (bl){
            System.out.println("注册成功");
        }
        else {
            System.out.println("注册失败");
        }
    }


    /*
    * 修改功能
    * */

    public void update(Users users){
//        实例化 UsersDaoImpl + UsersServiceImpl
        UsersDao usersDao= new UsersDaoImpl();
        UsersService usersService = new UsersServiceImpl(usersDao);

        boolean bl= usersService.update(users);
        if (bl){
            System.out.println("修改成功");
        }
        else {
            System.out.println("修改失败");
        }
    }
}
